<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@page import="com.lmpop.trade.ti_discountpolicy.*"%>
<%@page import="java.util.*"%>
<%@page import="com.lmpop.trade.ts_custclass.*" %>
<%@page import="com.lmpop.frame.util.PageTools"%>
<%@page import="com.lmpop.trade.ti_gift.Ti_giftInfo"%>
<%@page import="com.lmpop.trade.ti_voucher.*" %>
<%
	request.setCharacterEncoding("UTF-8");
	Hashtable ti_discountpolicy = new Hashtable();

	String req_member_level = "";

	String req_offer_type = "";

	String req_spending = "";

	String req_number = "";

	String req_discount = "";

	String req_ship_offer = "";

	String req_voucher_type = "";

	String req_voucher_num = "";

	String req_send_a_few = "";

	String req_gift_ids = "";

	String req_order_amount = "";

	String req_start_time = "";

	String req_end_time = "";

	String req_in_date = "";

	String req_user_id = "";

	if (request.getParameter("req_member_level") != null
			&& !request.getParameter("req_member_level").equals("")) {
		req_member_level = request.getParameter("req_member_level");
		ti_discountpolicy.put("member_level", req_member_level);
	}

	if (request.getParameter("req_offer_type") != null
			&& !request.getParameter("req_offer_type").equals("")) {
		req_offer_type = request.getParameter("req_offer_type");
		ti_discountpolicy.put("offer_type", req_offer_type);
	}

	if (request.getParameter("req_spending") != null
			&& !request.getParameter("req_spending").equals("")) {
		req_spending = request.getParameter("req_spending");
		ti_discountpolicy.put("spending", req_spending);
	}

	if (request.getParameter("req_number") != null
			&& !request.getParameter("req_number").equals("")) {
		req_number = request.getParameter("req_number");
		ti_discountpolicy.put("number", req_number);
	}

	if (request.getParameter("req_discount") != null
			&& !request.getParameter("req_discount").equals("")) {
		req_discount = request.getParameter("req_discount");
		ti_discountpolicy.put("discount", req_discount);
	}

	if (request.getParameter("req_ship_offer") != null
			&& !request.getParameter("req_ship_offer").equals("")) {
		req_ship_offer = request.getParameter("req_ship_offer");
		ti_discountpolicy.put("ship_offer", req_ship_offer);
	}

	if (request.getParameter("req_start_time") != null
			&& !request.getParameter("req_start_time").equals("")) {
		req_start_time = request.getParameter("req_start_time");
		ti_discountpolicy.put("start_time", req_start_time);
	}

	if (request.getParameter("req_end_time") != null
			&& !request.getParameter("req_end_time").equals("")) {
		req_end_time = request.getParameter("req_end_time");
		ti_discountpolicy.put("end_time", req_end_time);
	}

	if (request.getParameter("req_in_date") != null
			&& !request.getParameter("req_in_date").equals("")) {
		req_in_date = request.getParameter("req_in_date");
		ti_discountpolicy.put("in_date", req_in_date);
	}

	if (request.getParameter("req_user_id") != null
			&& !request.getParameter("req_user_id").equals("")) {
		req_user_id = request.getParameter("req_user_id");
		ti_discountpolicy.put("user_id", req_user_id);
	}

	Ti_discountpolicyInfo ti_discountpolicyInfo = new Ti_discountpolicyInfo();
	String iStart = "0";
	int limit = 20;
	if (request.getParameter("iStart") != null)
		iStart = request.getParameter("iStart");
	List list = ti_discountpolicyInfo.getListByPage(ti_discountpolicy,
			Integer.parseInt(iStart), limit);
	int counter = ti_discountpolicyInfo
			.getCountByObj(ti_discountpolicy);
	String pageString = new PageTools().getGoogleToolsBar(counter,
			"index.jsp?iStart=", Integer.parseInt(iStart), limit);
	Map custclassinfoMap = new Hashtable();
	custclassinfoMap.put("class_type","1");
	Ts_custclassInfo custclassinfo = new Ts_custclassInfo();
	String custclass_select =  custclassinfo.getSelectString(custclassinfoMap,"");
	Map classmaps=custclassinfo.getCust_classname();
	String[] arrays=new String[]{"购物送礼","满额打折","满量打折","运费优惠","满额赠送","买几送几"};

%>
<html>
	<head>

		<title>优惠策略设置</title>
		<link href="/program/admin/index/css/style.css" rel="stylesheet"
			type="text/css">
		<script type="text/javascript" src="/js/commen.js"></script>
		<script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
		<script type="text/javascript" src="index.js"></script>
	</head>

	<body>
		<table width="100%" cellpadding="0" cellspacing="0" border="0">
			<tr>
				<td width="90%">
					<h1>
						优惠策略设置
					</h1>
				</td>
				<td>
					<a href="addInfo.jsp"><img
							src="/program/admin/index/images/post.gif" />
					</a>
				</td>
			</tr>
		</table>

		<form action="index.jsp" name="indexForm" method="post">

			<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
				<tr>
					<td align="left">


						会员级别:
						<select name="req_member_level" id="member_level" onclick="setMember_level()" >
									<option value="">请选择</option>
								  	<%=custclass_select%>
						</select>
						&nbsp; 优惠类型:
						<select name="req_offer_type" id="offer_type" >
								  <option value="">请选择</option>
								  <option value="1">购物送礼</option>
								  <option value="2">满额打折</option>
								  <option value="3">满量打折</option>
								  <option value="4">运费优惠</option>
								  <option value="5">满额赠送</option>
								  <option value="6">买几送几</option>
						</select>
						&nbsp; 开始时间:
						<input name="req_start_time" type="text" size="10" maxlength="10" onfocus="WdatePicker({readOnly:true})"/>
						&nbsp; 结束时间:
						<input name="req_end_time" type="text" size="10" maxlength="10" onfocus="WdatePicker({readOnly:true})"/>
						&nbsp;

						<input name="searchInfo" type="button" value="查询"
							onclick="return search();" />
					</td>
				</tr>
			</table>

			<table width="100%" cellpadding="0" cellspacing="0" border="0"
				class="tablehe">
				<tr>
					<td><%=pageString%></td>
				</tr>
			</table>

			<%
				int listsize = 0;
				if (list != null && list.size() > 0) {
					listsize = list.size();
			%>

			<table width="100%" cellpadding="0" cellspacing="0" border="0"
				class="dl_bg">
				<tr>
					<td width="90%">
						<input type="button" name="delInfo" onclick="delIndexInfo()"
							value="删除" class="buttab" />
					</td>
					<td>
						总计:<%=counter%>条
					</td>
				</tr>
			</table>

			<table width="100%" cellpadding="1" cellspacing="1" class="listtab"
				border="0">
				<tr>
					<th width="5%" align="center">
						<input type="checkbox" name="checkall" id="checkall"
							onclick="selectAll()">
					</th>

					<th>
						会员级别
					</th>

					<th>
						优惠类型
					</th>

					<th>
						额满
					</th>

					<th>
						量满
					</th>

					<th>
						打折率
					</th>

					<th>
						运费优惠
					</th>

	                <th>
						商品优惠
					</th>
					<th>
						开始时间
					</th>

					<th>
						结束时间
					</th>

				</tr>


				<%
					List voucherlist=null;
					for (int i = 0; i < list.size(); i++) {
							Hashtable map = (Hashtable) list.get(i);
							String good_offer="",discount_id = "", member_level = "", offer_type = "", spending = "", number = "", discount = "", ship_offer = "", start_time = "", end_time = "", in_date = "", user_id = "";
							if (map.get("discount_id") != null)
								discount_id = map.get("discount_id").toString();
							if (map.get("member_level") != null)
								member_level = map.get("member_level").toString();
							if (map.get("offer_type") != null)
								offer_type = map.get("offer_type").toString();
							if (map.get("spending") != null)
								spending = map.get("spending").toString();
							if (map.get("number") != null)
								number = map.get("number").toString();
							if (map.get("discount") != null)
								discount = map.get("discount").toString();
							if (map.get("ship_offer") != null)
								ship_offer = map.get("ship_offer").toString();
							if (map.get("start_time") != null)
								start_time = map.get("start_time").toString();
							if (start_time.length() > 19)
								start_time = start_time.substring(0, 10);
							if (map.get("end_time") != null)
								end_time = map.get("end_time").toString();
							if (end_time.length() > 19)
								end_time = end_time.substring(0, 10);
							if (map.get("in_date") != null)
								in_date = map.get("in_date").toString();
							if (in_date.length() > 19)
								in_date = in_date.substring(0, 10);
							if (map.get("user_id") != null)
								user_id = map.get("user_id").toString();
							if (map.get("good_offer") != null)
								good_offer = map.get("good_offer").toString();	
								
				%>

				<tr>
					<td width="5%" align="center">
						<input type="checkbox" name="checkone<%=i%>" id="checkone<%=i%>"
							value="<%=discount_id%>" />
					</td>

					<td><%
						if(classmaps!=null&&classmaps.get(member_level)!=null ){%>
							<%=classmaps.get(member_level) %>
						<%}else{
					%>
						无
					<%} %></td>

					<td><%=arrays[Integer.parseInt(offer_type)-1]%></td>

					<td><%=spending%></td>

					<td><%=number%></td>

					<td><%=discount%></td>

					<td><%=ship_offer%></td>


					<td>
						<%
							if (good_offer.equals("1") ) {
										out.print("是");
									} else {
										out.print("否");
									}
						%>
					</td>
					<td><%=start_time%></td>

					<td><%=end_time%></td>

					<td width="10%">
						<a href="updateInfo.jsp?discount_id=<%=discount_id%>"><img
								src="/program/admin/images/edit.gif" title="编辑" />
						</a>
					</td>
					<td width="10%">
						<a href="javascript:deleteOneInfo('<%=discount_id%>','4826');"><img
								src="/program/admin/images/delete.gif" title="删除" />
						</a>
					</td>
				</tr>

				<%
					}
				%>

			</table>

			<table width="100%" cellpadding="0" cellspacing="0" border="0"
				class="dl_bg">
				<tr>
					<td width="90%">
						<input type="button" name="delInfo" onclick="delIndexInfo()"
							value="删除" class="buttab" />
					</td>
					<td>
						总计:<%=counter%>条
					</td>
				</tr>
			</table>
			<table width="100%" cellpadding="0" cellspacing="0" border="0"
				class="tablehe">
				<tr>
					<td><%=pageString%></td>
				</tr>
			</table>

			<%
				}
			%>

			<input type="hidden" name="listsize" id="listsize"
				value="<%=listsize%>" />
			<input type="hidden" name="pkid" id="pkid" value="" />
			<input type="hidden" name="bpm_id" id="bpm_id" value="4826" />
		</form>
	</body>

</html>
